package com.springboot.wisdom.common.common.bean;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class PageQueryDTO {
    @ApiModelProperty(value = "分页开关; 0=不分页, 1=需要分页", hidden = true)
    private int pagination = 1;

    @ApiModelProperty("当前页")
    private Integer current = 1;

    @ApiModelProperty("页码")
    private Integer pages = 1;

    @ApiModelProperty("每页最大条数")
    private Integer size = 10;

    @Deprecated
    public <T> Page<T> toPage() {
        return new Page<>(this.getPages(), this.getSize());
    }

    /**
     * 用于 结合Mybatis-plus-join 进行连表求总数。
     *
     * @param total       数据总数。
     * @param searchCount 是否开启 count 计算total。
     * @param <T>
     * @return
     */
    public <T> Page<T> toPage(Integer current, Integer size, Long total, Boolean searchCount) {
        return new Page<>(current, size, total, searchCount);
    }

}
